#include <stdio.h>

#define MAX_SIZE 100

void printMinefield(char minefield[MAX_SIZE][MAX_SIZE], int n, int m) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            printf("%c", minefield[i][j]);
        }
        printf("\n");
    }
}

void countMines(char minefield[MAX_SIZE][MAX_SIZE], int n, int m) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (minefield[i][j] == '?') {
                int mines = 0;
                for (int dx = -1; dx <= 1; dx++) {
                    for (int dy = -1; dy <= 1; dy++) {
                        if (dx == 0 && dy == 0) continue;
                        int nx = i + dx, ny = j + dy;
                        if (nx >= 0 && nx < n && ny >= 0 && ny < m && minefield[nx][ny] == '*') {
                            mines++;
                        }
                    }
                }
                minefield[i][j] = '0' + mines;
            }
        }
    }
}

int main() {
    char minefield[MAX_SIZE][MAX_SIZE];
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf(" %c", &minefield[i][j]);
        }
    }
    countMines(minefield, n, m);
    printMinefield(minefield, n, m);

    return 0;
}
